import { BaseEntity } from 'src/common/entitys/base';
import { DriverEntity } from 'src/modules/driver/entities/driver.entity';
import { EnterpriseEntity } from 'src/modules/enterprise/entities/enterprise.entity';
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm';

@Entity({ name: 'sys_carbill', comment: '出车单' })
export class CarbillEntity extends BaseEntity {
  @PrimaryGeneratedColumn({ name: 'carbill_id', comment: '出车单id 主键' })
  carbillId: number;

  @ManyToOne(() => DriverEntity)
  @JoinColumn({ name: 'driver_id' })
  driver: DriverEntity;

  @Column({ type: 'datetime', comment: '发车时间', name: 'depart_date' })
  departDate: Date;

  @Column({ type: 'datetime', nullable: true, comment: '到达时间', name: 'arrive_date' })
  arriveDate: Date;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '车辆经度', name: 'car_lon' })
  carLon: string;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '车辆纬度', name: 'car_lat' })
  carLat: string;

  @Column({ type: 'int', default: 1, comment: '1 未发车 2 运输中 3 已到达', name: 'carbill_status' })
  carbillStatus: number;

  @ManyToOne(() => EnterpriseEntity)
  @JoinColumn({ name: 'enterprise_id' })
  enterpriseId: EnterpriseEntity;
}
